import {defineStore} from "pinia";

export const useUserStore = defineStore("userState", {
    state: () => ({
        userInfo: {},
        login: false,
        token: ""
    }),
    getters: {
        loginState():boolean {
            return this.login
        }
    },
    actions: {
        setLoginInfo(userInfo:any, token:string){
            this.userInfo = userInfo
            this.token = token
            this.login = true
        },
        logout(){
            this.userInfo = {}
            this.token = ''
            this.login = false
        }
    },
    persist: true
})